package cn.wuxun.search.controller;

import java.util.ArrayList;import java.util.Arrays;
import java.util.List;

import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.core.JsonProcessingException;

import cn.wuxun.common.pojo.News;
import cn.wuxun.search.service.SearchService;
@RestController
@RequestMapping("search")
public class SearchController {
	@Autowired
	private SearchService searchService;
	
	//创建wuxun index的类型News数据
	@RequestMapping("create")
	public String createWXindex() {
		try {
			searchService.createWXindex();
			return "success";
		} catch (Exception e) {
			e.printStackTrace();
			return "fail";
		}
	}
	
	//支持的搜索功能
	@RequestMapping("query")
	public List<News> queryNews(String query){
		List<News> nList=searchService.queryNews(query);
		System.out.println(nList.get(1));
		return nList;
	}
}
